//
//  KeyboardEmoticonCollectionViewCell.swift
//  customKeyboard
//
//  Created by changhongliang on 2017/8/12.
//  Copyright © 2017年 richinfo. All rights reserved.
//

import UIKit

class KeyboardEmoticonCollectionViewCell: UICollectionViewCell {
    
    var emoticon: KeyboardEmoticon?
    {
        didSet{
            // 1.图片表情
            // 注意重用问题
            iconButton.setImage(UIImage(contentsOfFile: emoticon?.imagePath ?? ""), for: UIControlState.normal)
            
            // 2.Emoji表情
            iconButton.setTitle(emoticon!.codeStr, for: UIControlState.normal)
            // 3.删除按钮
            if emoticon!.isRemoveButton
            {
                iconButton.setImage(UIImage(named: "compose_emotion_delete"), for: UIControlState.normal)
                iconButton.setImage(UIImage(named: "compose_emotion_delete_highlighted"), for: UIControlState.highlighted)
            }

        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(iconButton)
        //设置控件尺寸的同时设置边距
        iconButton.frame = contentView.bounds.insetBy(dx: 4, dy: 4)
        iconButton.titleLabel?.font = UIFont.systemFont(ofSize: 32.0)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //MARK: - 懒加载
    lazy var iconButton:UIButton = {
        let btn = UIButton()
//        btn.backgroundColor = UIColor.white
        btn.isUserInteractionEnabled = false
        return btn
    }()
    
    
}
